<template>
    <div>
        <div class="b-c2">
            <div class="z-header width-75 tc c-f">
                <div @click="$router.back(-1)" class="lt">
                    <i class="iconfont icon-zuo m-t-18"></i>
                </div>
                <div class="fs-36">
                    好友信息
                </div>
            </div>
        </div>
        <div class="index-blank"></div>
        <div class="width-75 flex">
            <div class="row m-t-28 m-l-25">
                <div>
                    <img :src="friend.portrait" alt="" class="portrait">
                </div>
                <div class="m-l-14">
                    <h2 class="fs-36 c-3">{{friend.nickName}}</h2>
                    <p class="fs-24 c-3 m-t-18">年龄:{{friend.age}}</p>
                </div>
            </div>
            <div class="c-3 fs-30 dynamic-list m-t-28">
                座右铭:{{friend.motto}}
            </div>
        </div>
        <div class="index-blank m-t-28"></div>
        <div class="width-75 flex m-t-6">
            <div>
                <router-link :to="{path:'/chatContent', query:{'userName':userName}}">
                    <button class="friendRelease-button b-c2 c-f">聊天</button>
                </router-link>
            </div>
            <div>
                <button class="friendRelease-button b-c2 c-f" @click="deleteFriend()">删除</button>
            </div>
        </div>
    </div>
</template>
<script>
import { z } from '../../assets/js/common'
export default {
    data() {
        return {
            userName: this.$route.query.id, //id
            friend: "",
        }
    },
    methods: {
        release() {
            var params = new URLSearchParams();
            params.append("userName", this.userName);
            this.$http({
                method: "post",
                url: localPath + "/student/getMyUser",
                data: params
            }).then((data) => {
                this.friend = data.data.message;
                console.log(this.friend);
            }).catch((error) => {
                console.log(error);
            })
        },
        // 删除好友
        deleteFriend(){
            var params = new URLSearchParams();
            params.append("faccid", this.userName);
            this.$http({
                method: "post",
                url: localPath + "/im/deleteFriend",
                data: params
            }).then((data) => {
                 
                console.log(data);
            }).catch((error) => {
                console.log(error);
            })
        }
    },
    mounted() {
        this.release();
          document.addEventListener(z());
    }
}
</script>
<style>
.friendRelease-button {
    width: 2rem;
    height: .7rem;
}
</style>
